/*
 * pb_adv.h
 *
 *  Created on: 2024年6月24日
 *      Author: panchip
 */

#ifndef _PB_ADV_H_
#define _PB_ADV_H_

#include "utils/defs_types.h"
#include "utils/stimer.h"
#include "utils/mdc.h"
#include "utils/queue.h"

typedef struct pbAdvPkt_s{
	struct pbAdvPkt_s  *pNext;
	uint16_t            advInterval;  //ms
	uint16_t            advDataLen;
	uint8_t             advCnt;
	uint8_t             value[0];
}pbAdvPkt_t;
#define MESH_ADV_HEAD_SIZE   sizeof(pbAdvPkt_t)
#define MESH_ADV_DATA_SIZE   31

typedef struct{
	uint8_t      busy;
	queue_t      txQueue;
	MdcTimer_t   advTimer;
}pbAdvCb_t;

void MESH_AdvInit(void);
int MESH_AdvSend(uint16_t intervalMs, uint8_t advCnt, uint8_t *pdata, uint32_t len);


/* Only internal use */
bool_t MESH_IsAdvBusy(void);
void MESH_AdvClearFlag(void);
int MESH_AdvStart(void);
void MESH_AdvStop(void);
void MESH_AdvSendEndHandler(void);

#endif /* _PB_ADV_H_ */
